<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Login extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model("login_model");
    }


    /**
     * 载入后台登陆界面
     */
    public function index()
    {
        $this->load->view("manage/login.html");
    }

    /**
     * 验证码
     */
    public function captcha_code()
    {
        $this->load->library('Captcha');
        $this->captcha->get_code(4, 50, 20);
    }
    
    public function check()
    {
        $username = $this->input->post("username");
        $password = $this->input->post("password");
        $user_type = $this->input->post("user_type");
        $captcha_code = $this->input->post('captcha_code');
        $result = $this->login_model->do_login($username, $password, $captcha_code, $user_type);
        echo json_encode($result);
    }
    

    /**
     * 注销登陆
     */
    public function logout()
    {
        $this->login_model->logout();
    }
}